﻿' ///////////////////////////////////////////////////////////////
' // This is generated code. 
' //////////////////////////////////////////////////////////////
' // Code is generated using LLBLGen Pro version: 2.6
' // Code is generated on: lundi 28 septembre 2009 23:24:55
' // Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20
' // Templates vendor: Solutions Design.
' // Templates version: 
' //////////////////////////////////////////////////////////////
Imports System
Imports System.Collections.Generic
Imports Aricie.DNN.Services.Url.FriendlyUrl.EntityClasses
Imports Aricie.DNN.Services.Url.FriendlyUrl.HelperClasses
Imports Aricie.DNN.Services.Url.FriendlyUrl.RelationClasses

Imports SD.LLBLGen.Pro.ORMSupportClasses

' __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
' __LLBLGENPRO_USER_CODE_REGION_END
Namespace Aricie.DNN.Services.Url.FriendlyUrl.FactoryClasses

	''' <summary>general base Class For the generated factories</summary>
	<Serializable()> _
	Public Class EntityFactoryBase2
			Inherits EntityFactoryCore2
		Private _entityName As String
		Private _typeOfEntity As Aricie.DNN.Services.Url.FriendlyUrl.EntityType
		
		''' <summary>CTor</summary>
		''' <param name="entityName">Name of the entity.</param>
		''' <param name="typeOfEntity">The type of entity.</param>
		Public Sub New(entityName As String, typeOfEntity As Aricie.DNN.Services.Url.FriendlyUrl.EntityType)
			_entityName = entityName
			_typeOfEntity = typeOfEntity
		End Sub
		
		''' <summary>Creates a New entity instance using the GeneralEntityFactory In the generated code, using the passed In entitytype value</summary>
		''' <param name="entityTypeValue">The entity type value of the entity To create an instance For.</param>
		''' <returns>New IEntity instance</returns>
		Public Overrides Overloads Function CreateEntityFromEntityTypeValue(entityTypeValue As Integer) As IEntity2
			Return GeneralEntityFactory.Create(CType(entityTypeValue, Aricie.DNN.Services.Url.FriendlyUrl.EntityType))
		End Function
		
		''' <summary>Creates, using the generated EntityFieldsFactory, the IEntityFields2 object for the entity to create.</summary>
		''' <returns>Empty IEntityFields2 object.</returns>
		Public Overrides Function CreateFields() As IEntityFields2
			Return EntityFieldsFactory.CreateEntityFieldsObject(_typeOfEntity)
		End Function
		
		''' <summary>Creates the relations collection To the entity To Join all targets so this entity can be fetched. </summary>
		''' <param name="objectAlias">The object alias to use for the elements in the relations.</param>
		''' <returns>null If the entity isn't in a hierarchy of type TargetPerEntity, otherwise the relations collection needed to
		''' Join all targets together To fetch all subtypes of this entity And this entity itself</returns>
		Public Overrides Function  CreateHierarchyRelations(objectAlias As String) As IRelationCollection
			Return InheritanceInfoProviderSingleton.GetInstance().GetHierarchyRelations(_entityName, objectAlias)
		End Function

		''' <summary>This method retrieves, using the InheritanceInfoprovider, the factory For the entity represented by the values passed In.</summary>
		''' <param name="fieldValues">Field values read from the db, To determine which factory To Return, based On the field values passed In.</param>
		''' <param name="entityFieldStartIndexesPerEntity">indexes into values where per entity type their own fields start.</param>
		''' <returns>the factory For the entity which Is represented by the values passed In.</returns>
		Public Overrides Function GetEntityFactory(fieldValues As Object(), entityFieldStartIndexesPerEntity As Dictionary(Of String, Integer)) As IEntityFactory2
			Dim toReturn As IEntityFactory2 =  CType(InheritanceInfoProviderSingleton.GetInstance().GetEntityFactory(_entityName, fieldValues, entityFieldStartIndexesPerEntity), IEntityFactory2)
			If toReturn Is Nothing Then
				toReturn = Me
			End If
			Return toReturn
		End Function
		
		''' <summary>Gets a predicateexpression which filters On the entity With type belonging To this factory.</summary>
		''' <param name="objectAlias">The object alias to use for the predicate(s).</param>
		''' <param name="negate">Flag To produce a Not filter, (True), Or a normal filter (False). </param>
		''' <returns>ready To use predicateexpression, Or an empty predicate expression If the belonging entity isn't a hierarchical type.</returns>
		Public Overrides Function GetEntityTypeFilter(negate As Boolean, objectAlias As String) As IPredicateExpression
			Return InheritanceInfoProviderSingleton.GetInstance().GetEntityTypeFilter(_entityName, objectAlias, negate)
		End Function

		''' <summary>returns the name of the entity this factory Is For, e.g. "EmployeeEntity"</summary>
		Public Overrides ReadOnly Property ForEntityName() As String
			Get 
				Return _entityName
			End Get
		End Property
	End Class
	
	''' <summary>
	''' Factory to create new, empty FupPatternMappingEntity objects.
	''' </summary>
	<Serializable()> _
	Public Class FupPatternMappingEntityFactory 
		Inherits EntityFactoryBase2

		''' <summary>CTor</summary>
		Public Sub New()
			MyBase.New("FupPatternMappingEntity", Aricie.DNN.Services.Url.FriendlyUrl.EntityType.FupPatternMappingEntity)
		End Sub

		''' <summary>Creates a new, empty FupPatternMappingEntity object.</summary>
		''' <returns>A new, empty FupPatternMappingEntity object.</returns>
		Public Overrides Overloads Function Create() As IEntity2
			Dim toReturn As IEntity2 = New FupPatternMappingEntity()
			
			' __LLBLGENPRO_USER_CODE_REGION_START CreateNewFupPatternMapping
			' __LLBLGENPRO_USER_CODE_REGION_END		
			Return toReturn
		End Function
		
		''' <summary>Creates a new FupPatternMappingEntity instance and will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		''' <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		''' <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		Public Overrides Overloads Function Create(fields As IEntityFields2) As IEntity2
			Dim toReturn As IEntity2 = New FupPatternMappingEntity(fields)
			
			' __LLBLGENPRO_USER_CODE_REGION_START CreateNewFupPatternMappingUsingFields
			' __LLBLGENPRO_USER_CODE_REGION_END		
			Return toReturn
		End Function
				
		''' <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		''' <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		Public Overrides Function CreateEntityCollection() As IEntityCollection2 
			Return New EntityCollection(Of FupPatternMappingEntity)(Me)
		End Function



#Region "Included Code"

#End Region
	End Class
	
	''' <summary>
	''' Factory to create new, empty FupUrlMappingEntity objects.
	''' </summary>
	<Serializable()> _
	Public Class FupUrlMappingEntityFactory 
		Inherits EntityFactoryBase2

		''' <summary>CTor</summary>
		Public Sub New()
			MyBase.New("FupUrlMappingEntity", Aricie.DNN.Services.Url.FriendlyUrl.EntityType.FupUrlMappingEntity)
		End Sub

		''' <summary>Creates a new, empty FupUrlMappingEntity object.</summary>
		''' <returns>A new, empty FupUrlMappingEntity object.</returns>
		Public Overrides Overloads Function Create() As IEntity2
			Dim toReturn As IEntity2 = New FupUrlMappingEntity()
			
			' __LLBLGENPRO_USER_CODE_REGION_START CreateNewFupUrlMapping
			' __LLBLGENPRO_USER_CODE_REGION_END		
			Return toReturn
		End Function
		
		''' <summary>Creates a new FupUrlMappingEntity instance and will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		''' <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		''' <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		Public Overrides Overloads Function Create(fields As IEntityFields2) As IEntity2
			Dim toReturn As IEntity2 = New FupUrlMappingEntity(fields)
			
			' __LLBLGENPRO_USER_CODE_REGION_START CreateNewFupUrlMappingUsingFields
			' __LLBLGENPRO_USER_CODE_REGION_END		
			Return toReturn
		End Function
				
		''' <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		''' <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		Public Overrides Function CreateEntityCollection() As IEntityCollection2 
			Return New EntityCollection(Of FupUrlMappingEntity)(Me)
		End Function



#Region "Included Code"

#End Region
	End Class

	''' <summary>Factory to create new, empty Entity objects based on the entity type specified. Uses entity specific factory objects</summary>
	<Serializable()> _
	Public Class GeneralEntityFactory
		''' <summary>Creates a new, empty Entity object of the type specified</summary>
		''' <param name="entityTypeToCreate">The entity type to create.</param>
		''' <returns>A new, empty Entity object.</returns>
		Public Shared Function Create(entityTypeToCreate As Aricie.DNN.Services.Url.FriendlyUrl.EntityType) As IEntity2 
			Dim factoryToUse As IEntityFactory2 = Nothing
			Select Case entityTypeToCreate
				Case Aricie.DNN.Services.Url.FriendlyUrl.EntityType.FupPatternMappingEntity
					factoryToUse = New FupPatternMappingEntityFactory()
				Case Aricie.DNN.Services.Url.FriendlyUrl.EntityType.FupUrlMappingEntity
					factoryToUse = New FupUrlMappingEntityFactory()
			End Select
			Dim toReturn As IEntity2 = Nothing
			if Not factoryToUse Is Nothing Then
				toReturn = factoryToUse.Create()
			End If
			Return toReturn
		End Function		
	End Class
	
	''' <summary>Class which Is used To obtain the entity factory based On the .NET type of the entity. </summary>
	<Serializable()> _
	Public Class EntityFactoryFactory
#If CF Then
		''' <summary>Gets the factory of the entity With the Aricie.DNN.Services.Url.FriendlyUrl.EntityType specified</summary>
		''' <param name="typeOfEntity">The type of entity.</param>
		''' <returns>factory To use Or null If Not found</returns>
		Public Shared Function GetFactory(typeOfEntity As Aricie.DNN.Services.Url.FriendlyUrl.EntityType) As IEntityFactory2
			Return GeneralEntityFactory.Create(typeOfEntity).GetEntityFactory()
		End Function
#Else
		Private Shared _factoryPerType As Dictionary(Of Type, IEntityFactory2) = New Dictionary(Of Type, IEntityFactory2)()

		''' <summary>Initializes the <see cref="EntityFactoryFactory"/> Class.</summary>
		Shared Sub New()
			Dim entityTypeValues As Array = [Enum].GetValues(GetType(Aricie.DNN.Services.Url.FriendlyUrl.EntityType))
			For Each entityTypeValue As Integer In entityTypeValues
				Dim dummy As IEntity2 = GeneralEntityFactory.Create(CType(entityTypeValue, Aricie.DNN.Services.Url.FriendlyUrl.EntityType))
				_factoryPerType.Add(CType(dummy, Object).GetType(), dummy.GetEntityFactory())
			Next
		End Sub

		''' <summary>Gets the factory of the entity With the .NET type specified</summary>
		''' <param name="typeOfEntity">The type of entity.</param>
		''' <returns>factory To use Or null If Not found</returns>
		Public Shared Function GetFactory(typeOfEntity As Type) As IEntityFactory2
			Dim toReturn As IEntityFactory2  = Nothing
			_factoryPerType.TryGetValue(typeOfEntity, toReturn)
			Return toReturn
		End Function

		''' <summary>Gets the factory of the entity With the Aricie.DNN.Services.Url.FriendlyUrl.EntityType specified</summary>
		''' <param name="typeOfEntity">The type of entity.</param>
		''' <returns>factory To use Or null If Not found</returns>
		Public Shared Function GetFactory(typeOfEntity As Aricie.DNN.Services.Url.FriendlyUrl.EntityType) As IEntityFactory2
			Return GetFactory(CType(GeneralEntityFactory.Create(typeOfEntity), Object).GetType())
		End Function
#End If
	End Class
		
	''' <summary>Element creator For creating project elements from somewhere Else, like inside Linq providers.</summary>
	Public Class ElementCreator 
		Inherits ElementCreatorBase
		Implements IElementCreator2
	
		''' <summary>Gets the factory of the Entity type with the Aricie.DNN.Services.Url.FriendlyUrl.EntityType value passed in</summary>
		''' <param name="entityTypeValue">The entity type value.</param>
		''' <returns>the entity factory of the entity type or null if not found</returns>
		Public Function GetFactory(entityTypeValue As Integer) As IEntityFactory2 Implements IElementCreator2.GetFactory
			Return CType(GetFactoryImpl(entityTypeValue), IEntityFactory2)
		End Function
		
		''' <summary>Gets the factory of the Entity type With the .NET type passed In</summary>
		''' <param name="typeOfEntity">The type of entity.</param>
		''' <returns>the entity factory of the entity type Or null If Not found</returns>
		Public Function GetFactory(typeOfEntity As Type) As IEntityFactory2 Implements IElementCreator2.GetFactory
			Return CType(GetFactoryImpl(typeOfEntity), IEntityFactory2)
		End Function

		''' <summary>Creates a New resultset fields Object With the number of field slots reserved As specified</summary>
		''' <param name="numberOfFields">The number of fields.</param>
		''' <returns>ready To use resultsetfields Object</returns>
		Public Function CreateResultsetFields(numberOfFields As Integer) As IEntityFields2  Implements IElementCreator2.CreateResultsetFields
			Return New ResultsetFields(numberOfFields)
		End Function
		
		''' <summary>Creates a New dynamic relation instance</summary>
		''' <param name="leftOperand">The Left operand.</param>
		''' <returns>ready To use dynamic relation</returns>
		Public Overrides Overloads Function CreateDynamicRelation(leftOperand As DerivedTableDefinition) As IDynamicRelation
			Return New DynamicRelation(leftOperand)
		End Function

		''' <summary>Creates a New dynamic relation instance</summary>
		''' <param name="leftOperand">The Left operand.</param>
		''' <param name="joinType">Type of the Join. If None Is specified, Inner Is assumed.</param>
		''' <param name="rightOperand">The Right operand.</param>
		''' <param name="onClause">The On clause For the Join.</param>
		''' <returns>ready To use dynamic relation</returns>
		Public Overrides Overloads Function CreateDynamicRelation(leftOperand As DerivedTableDefinition, joinType As JoinHint, rightOperand As DerivedTableDefinition, onClause As IPredicate) As IDynamicRelation
			Return New DynamicRelation(leftOperand, joinType, rightOperand, onClause)
		End Function

		''' <summary>Creates a New dynamic relation instance</summary>
		''' <param name="leftOperand">The Left operand.</param>
		''' <param name="joinType">Type of the Join. If None Is specified, Inner Is assumed.</param>
		''' <param name="rightOperandEntityName">Name of the entity, which Is used As the Right operand.</param>
		''' <param name="aliasRightOperand">The Alias of the Right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
		''' <param name="onClause">The On clause For the Join.</param>
		''' <returns>ready To use dynamic relation</returns>
		Public Overrides Overloads Function CreateDynamicRelation(leftOperand As DerivedTableDefinition, joinType As JoinHint, rightOperandEntityName As String, aliasRightOperand As String, onClause As IPredicate) As IDynamicRelation
			Return New DynamicRelation(leftOperand, joinType, CType([Enum].Parse(GetType(Aricie.DNN.Services.Url.FriendlyUrl.EntityType), rightOperandEntityName, False), Aricie.DNN.Services.Url.FriendlyUrl.EntityType), aliasRightOperand, onClause)
		End Function

		''' <summary>Creates a New dynamic relation instance</summary>
		''' <param name="leftOperandEntityName">Name of the entity which Is used As the Left operand.</param>
		''' <param name="joinType">Type of the Join. If None Is specified, Inner Is assumed.</param>
		''' <param name="rightOperandEntityName">Name of the entity, which Is used As the Right operand.</param>
		''' <param name="aliasLeftOperand">The Alias of the Left operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
		''' <param name="aliasRightOperand">The Alias of the Right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
		''' <param name="onClause">The On clause For the Join.</param>
		''' <returns>ready To use dynamic relation</returns>
		Public Overrides Overloads Function CreateDynamicRelation(leftOperandEntityName As String, joinType As JoinHint, rightOperandEntityName As String, aliasLeftOperand As String, aliasRightOperand As String, onClause As IPredicate) As IDynamicRelation
			Return New DynamicRelation(CType([Enum].Parse(GetType(Aricie.DNN.Services.Url.FriendlyUrl.EntityType), leftOperandEntityName, False), Aricie.DNN.Services.Url.FriendlyUrl.EntityType), joinType, CType([Enum].Parse(GetType(Aricie.DNN.Services.Url.FriendlyUrl.EntityType), rightOperandEntityName, False), Aricie.DNN.Services.Url.FriendlyUrl.EntityType), aliasLeftOperand, aliasRightOperand, onClause)
		End Function
				
		''' <summary>Obtains the inheritance info provider instance from the singleton </summary>
		''' <returns>The singleton instance of the inheritance info provider</returns>
		Public Overrides Function ObtainInheritanceInfoProviderInstance() As IInheritanceInfoProvider
			Return InheritanceInfoProviderSingleton.GetInstance()
		End Function

		''' <summary>Implementation of the routine which gets the factory of the Entity type With the Aricie.DNN.Services.Url.FriendlyUrl.EntityType value passed In</summary>
		''' <param name="entityTypeValue">The entity type value.</param>
		''' <returns>the entity factory of the entity type Or null If Not found</returns>
		Protected Overrides Function GetFactoryImpl(entityTypeValue As Integer) As IEntityFactoryCore
			Return EntityFactoryFactory.GetFactory(CType(entityTypeValue, Aricie.DNN.Services.Url.FriendlyUrl.EntityType))
		End Function
		
#If Not CF Then
		''' <summary>Implementation of the routine which gets the factory of the Entity type With the .NET type passed In</summary>
		''' <param name="typeOfEntity">The type of entity.</param>
		''' <returns>the entity factory of the entity type Or null If Not found</returns>
		Protected Overrides Function GetFactoryImpl(typeOfEntity As Type) As IEntityFactoryCore 
			Return EntityFactoryFactory.GetFactory(typeOfEntity)
		End Function
#End If
	End Class

End Namespace
